package com.briup.cms.web.controller;

import com.briup.cms.bean.Role;
import com.briup.cms.service.IRoleService;
import com.briup.cms.utils.Message;
import com.briup.cms.utils.MessageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@Api(description = "角色管理")
@RestController
@RequestMapping("/cms_role")
public class RoleController {
@Autowired
private IRoleService roleService;
@ApiOperation("查询所有")
@GetMapping("findAll")
    public Message findAll() {
    List<Role> list =roleService.findAll();
        return MessageUtil.success(list);
    }
@ApiOperation("保存或更新")
@GetMapping("saveOrUpdate")
    public Message saveOrUpdate(Role role)
       {
          roleService.saveOrUpdate(role);
       return MessageUtil.success(role);
       }
@ApiOperation("删除")
@GetMapping("deleteById")
       public Message deleteById(Long id){
            roleService.deleteById(id);
            return MessageUtil.success(id);
    }
}
